<?php
header('Content-Type: text/html; charset=utf-8');
?>

<link rel="stylesheet" type="text/css" href="js/jquery.wysiwyg.css" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>

<script type="text/javascript">
    $(function()
    {
        $('#wysiwyg').wysiwyg();
    });
</script>


<form onsubmit="return validateForm();" method="post" 
      action="post.php">

    <p><strong><label for="title">Tiêu đề:</label></strong> <input type="text" id ="title"name="title" name="title" size="40" /></p>
    <p> <lable id="error"></lable></p>
<p><textarea name="wysiwyg" id="wysiwyg" rows="10" cols="60"></textarea></p>
<p><input type="submit" name="submit" id="submit" value="Xuất bản"></p>

<script type='text/javascript'>

    function validateForm(){
        // Make quick references to our fields
        var title = document.getElementById('title');
        var content = document.getElementById('wysiwyg');	
        // Check each input in the order that it appears in the form!
        if(isEmpty(title, "*Chưa nhập tiêu đề") || isEmpty(content,"*Chưa nhập nội dung")){
            return false;
        }
        return true;
	
    }
    function isEmpty(elem, helperMsg){
        if(elem.value.length == 0){
            var errorLable = document.getElementById('error');
            errorLable.innerHTML = helperMsg;
            errorLable.style.fontWeight = "Bold";
            errorLable.style.color = "Red";
            errorLable.style.fontFamily="arial,sans-serif";
            errorLable.style.fontSize = "10px";
            
            //alert(helperMsg);
            elem.focus(); // set the focus to this input
            return true;
        }
        return false;
    }

</script>
</form>
